package com.itheima.d3_charset;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws UnsupportedEncodingException {
        //编码
        String data ="a我b";
        byte[] bytes = data.getBytes();
        System.out.println(Arrays.toString(bytes));

        //按照制定字符进行编码
        byte[] bytes2 = data.getBytes("GBK");
        System.out.println(Arrays.toString(bytes2));

        //解码
        String s = new String(bytes2);
        System.out.println(s);

        //按照指定字符进行解码
        String s2 = new String(bytes2,"GBK");
        System.out.println(s2);
    }
}
